/*
*    Qizx/open 3.0 beta
*
* This code is the open-source version of Qizx.
* Copyright (C) 2004-2009 Axyana Software -- All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License 
*  Version 1.1 (the "License"); you may not use this file except in 
*  compliance with the License. You may obtain a copy of the License at
*  http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
*  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
*  for the specific language governing rights and limitations under the
*  License.
*
* The Initial Developer of the Original Code is Xavier Franc - Axyana Software.
*
*/
using System;
using Comparison = System.Qizx.Util.Basic.Comparison;
using ComparisonContext = System.Qizx.XQuery.ComparisonContext;
using DataModelException = System.Qizx.Api.DataModelException;
using DateTimeException = System.Qizx.Api.Util.XQDateTimeException;
using Duration = System.Qizx.Api.Util.XQDuration;
using EvaluationException = System.Qizx.Api.EvaluationException;
using FileUtil = System.Qizx.Util.Basic.FileUtil;
using NamespaceContext = System.Qizx.Util.NamespaceContext;
using Node = System.Qizx.Api.Node;
using PushStreamToDOM = System.Qizx.Api.Util.PushStreamToDOM;
using QizxException = System.Qizx.Api.QizxException;
using QName = System.Qizx.Api.QName;
using StringValue = System.Qizx.XQuery.Dt.StringValue;
using UntypedAtomicType = System.Qizx.XQuery.Dt.UntypedAtomicType;
using URI = System.Uri;
using XMLPullStream = System.Qizx.Api.XMLPullStream;
using XQDateTimeBase = System.Qizx.Api.Util.XQDateTimeBase;
using XQItem = System.Qizx.XQuery.XQItem;
using XQValue = System.Qizx.XQuery.XQValue;

namespace System.Qizx.Xdm {
    /// <summary> Basic in-core Implementation of XQuery Data Model. Used for constructed tree
    /// fragments.
    /// </summary>
    [Serializable]
    public class CoreDataModel {
        protected internal string _baseURI;

        public CoreDataModel(string baseURI) {
            this._baseURI = baseURI;
        }

        // --------------- static construction ------------------------------------

        public virtual XdmDocument newDocumentNode() {
            XdmDocument doc = new XdmDocument(this);
            _ownerDocument = doc;
            return doc;
        }

        public virtual XdmElement newElement(IQName name) {
            return new XdmElement(this, name);
        }

        public virtual XdmAttribute newAttribute(IQName name) {
            return new XdmAttribute(this, name);
        }

        public virtual XdmNSAttribute newNSNode(string prefix) {
            return new XdmNSAttribute(this, prefix);
        }

        public virtual XdmText newTextNode(string value_Renamed) {
            return new XdmText(this, value_Renamed);
        }

        public virtual XdmText newTextNode() {
            return new XdmText(this);
        }

        public virtual XdmProcessingInstruction newPINode(string target) {
            return new XdmProcessingInstruction(this, target, "");
        }

        public virtual XdmProcessingInstruction newPINode(string target, string value_Renamed) {
            return new XdmProcessingInstruction(this, target, value_Renamed);
        }

        public virtual XdmComment newCommentNode(string value_Renamed) {
            return new XdmComment(this, value_Renamed);
        }

        #region Extensions
        internal XdmDocument _ownerDocument;
        public virtual XdmDocument OwnerDocument {
            get {
                return _ownerDocument;
            }
        }
        #endregion
    }
}